<html>
<head>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<title>RESTful</title>

<script type="text/javascript">

$(function() {


function getMarcasAjax() {
        $.ajax(
        {
            type: "GET",
            url: "http://localhost:8080/Xulapa-war/rest/xulapa/marcas?callback=?",
            contentType: "application/x-www-form-urlencoded",
            dataType: "jsonp",
            success: loadTwitterListFeed
        });
}

function loadTwitterListFeed(data, textStatus, XMLHttpRequest) {
	alert(data);
	$('#content').html(data.marca[0].nome);
}


function getMarcas() {
//             http://fgaucho.dyndns.org:8080/arena-http/homework/jsonp?competition="+competition+"&jsoncallback=?
	$.getJSON('/Xulapa-war/rest/xulapa/marcasp?jsoncallback=?', function(data) {
	alert(data);
		jQuery.each(data, function(i, fn) {
			$('#content').html(fn.nome);
		});
		
	});

}

function parse() {
alert('oioioi');
}

//set effect from select menu value
$("#getMarcas").click(function() {
	getMarcas();
	return false;
	
});

$("#getMarcasAjax").click(function() {
	getMarcasAjax();
	return false;
	
});

});

</script>


<script>
/*
  jQuery.noConflict();
  jQuery.ajaxSetup ({ cache: true });
    jQuery(document).ready(function(){
        loadHomeworks("PUJCE-09"); 
        loadHomeworks("PUJCE-08");
        loadHomeworks("PUJCE-07");
        function loadHomeworks(competition) {
          var div = document.createElement('div');
          div.className="history";
          div.id = competition;
          var url = "http://fgaucho.dyndns.org:8080/arena-http/homework/jsonp?competition="+competition+"&jsoncallback=?";
          jQuery.getJSON(url,
          function(data){
              var oUL = document.createElement('ul');
              oUL.className="history2";
              div.appendChild(oUL);
              
            jQuery.each(data, function(i, fn) {
                  var avatar = document.createElement('img');
                  for ( var a in fn.author )
                  {
                      var author = fn.author[a];
                      for ( var r in author.role )
                      {
                       if(author.role[r].name == 'STUDENT') {
                        avatar.src = author.avatar + '?s=48&r=r';
                        avatar.title = author.name;
                        break;
                       }
                      }
                      if(avatar.src) {
                          break;
                      }
                  } 
                  var anchor = document.createElement('a');
                  anchor.href = fn.url;
                  anchor.appendChild(avatar);
                  var p = document.createElement('p');
                  p.appendChild(anchor);
                  var item = document.createElement('li');
                  item.appendChild(p);
                  oUL.insertBefore(item, oUL.firstChild);
                  
              }); 
          });
          var outterDiv = document.getElementById("homeworks");
          outterDiv.appendChild(div);
        }
        
    });
	*/
</script>


</head>
<body>

<div id="content"></div>

<button id="getMarcas" type="button">get marcas</button>
<br/>
<button id="getMarcasAjax" type="button">getMarcasAjax</button>
</body>
</html>